package com.ndd.service.impl;

import com.ndd.enums.ServiceCode;
import com.ndd.exception.ServiceException;
import com.ndd.mapper.ProductMapper;
import com.ndd.service.ProductService;
import com.ndd.vo.ProductVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @ProjectName: cmall-ybu
 * @Titile: ProductServiceImpl
 * @Author: Lucky
 * @Description: 商品实现类
 */
@Service
@Transactional
public class ProductServiceImpl implements ProductService {
    @Autowired
    private ProductMapper productMapper;
    @Override
    public List<ProductVO> getNewProductList() {
        List<ProductVO> newProductList = productMapper.getNewProductList();
        //检查以前的代码是否有bug
        if(newProductList==null || newProductList.size()==0){
            throw new ServiceException(ServiceCode.ERR_NOT_FOUND,"没有新商品");
        }
        return newProductList;
    }
}
